<div class="row">
<div class="col-xs-12">
	<form class="form-horizontal" role="form" action="" method="post" id="form">

	<div class="form-group">
    	<label class="col-sm-3 control-label no-padding-right">
    	<span class="red">*</span>管理账号：
    	</label>
    	<div class="col-sm-9">
        <input type="text" class="col-xs-10 col-sm-5" value="<?php echo $username?>" readonly="readonly">
    	</div>
    </div>
    <div class="space-4"></div>
		
				
	<div class="form-group">
		<label class="col-sm-3 control-label no-padding-right" for="oldpass">
			<span class="red">*</span>当前密码
		</label>
        <div class="col-sm-9">
    		<input type="password" name="oldpass" id="oldpass"
    			value="<?php echo set_value('oldpass');?>" class="col-xs-10 col-sm-5" />
			
			<p class="red"><?php echo form_error('oldpass');?></p>
		</div>
	</div>
	<div class="space-4"></div>
	
	
    <div class="form-group">
    	<label class="col-sm-3 control-label no-padding-right" for="newpass"><span class="red">*</span>新密码
    	</label>
    	<div class="col-sm-9">
    		<input type="password" name="newpass" id="newpass"
    			value="<?php echo set_value('newpass');?>" class="col-xs-10 col-sm-5" />
    		<p class="red"><?php echo form_error('newpass');?></p>
    	</div>
    </div>
    <div class="space-4"></div>

	<div class="form-group">
		<label class="col-sm-3 control-label no-padding-right" for="newpass2"><span class="red">*</span>密码确认
		</label>
		<div class="col-sm-9">
		    <input type="password" name="newpass2" id="newpass2"
			value="<?php echo set_value('newpass2');?>" class="ol-xs-10 col-sm-5" />
			<p class="red"><?php echo form_error('newpass2');?></p>
		</div>
	</div>
	
	<div class="clearfix form-actions">
    	<div class="col-md-offset-3 col-md-9">
    		<button class="btn btn-info btn-sm" type="submit">
    			<i class="ace-icon fa fa-check bigger-110"></i>
    			提交
    		</button>
    
    		&nbsp; &nbsp; &nbsp;
    		<button class="btn btn-sm" type="reset">
    			<i class="ace-icon fa fa-undo bigger-110"></i>
    			重置
    		</button>
    	</div>
    </div>
    
	</form>
</div>
</div>

<script> 
$(function(){
	function getError( _this,error ){	
		_this.siblings(".error").remove();
		_this.parent().append('<div class="red">'+error+'</div>');	
	}
	
	function check( _this,error,re ){ 
		if( re ){
			if( re.test(_this.val()) == false ){
				getError( _this,error );		
				return false;
			}	
			return true;
		}else{		
			if( _this.val() == '' ){
				getError( _this,error );
				return false;
			}
			return true;
		}
	}
	
	// 判断位数
	function isBit( _this,min,max,error ){
		if( min > _this.val().length || _this.val().length > max ){
			getError( _this,error );
			return false;
		}
		return true;
	}
	
	$( '#form' ).on( 'submit',function(){ 
		if( !check( $('#oldpass'),"当前密码不能为空！") ) return false; 
		if( !check( $('#newpass'),"新密码不能为空！") ) return false; 
		if( !check( $('#newpass2'),"确认密码不能为空！") ) return false;
		
		
		if( !isBit( $('#oldpass'),6,12,"当前密码必须是6-12位！" ) ) return false;		
		if( !isBit( $('#newpass'),6,12,"新密码必须是6-12位！" ) ) return false;
		if( !isBit( $('#newpass2'),6,12,"确认密码必须是6-12位！" ) ) return false;
    	
    	if( $('#newpass').val() != $('#newpass2').val() ){
    		getError( $('#newpass2'),'新密码与确认密码不一致！' );
    		return false;
    	}
    	
	});

	
});
</script>


